<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SAMSUNG三星商城后台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <link rel="shortcut icon" href="../x-admin/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="../x-admin/css/font.css">
    <link rel="stylesheet" href="../x-admin/css/xadmin.css">


    <link rel="stylesheet" href="https://cdn.bootcss.com/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcss.com/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="../x-admin/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../x-admin/js/xadmin.js"></script>



</head>
<body>
<!-- 顶部开始 -->
<div class="container">
    <div class="logo"><a href="htindex">SAMSUNG</a></div>
    <div class="open-nav"><i class="iconfont">&#xe699;</i></div>
    <ul class="layui-nav right" lay-filter="">
        <li class="layui-nav-item">
            <a href="javascript:;">admin</a>
            <dl class="layui-nav-child"> <!-- 二级菜单 -->
                <dd><a href="">个人信息</a></dd>
                <dd><a href="">切换帐号</a></dd>
                <dd><a href="login">退出</a></dd>
            </dl>
        </li>
        <li class="layui-nav-item"><a href="index">前台首页</a></li>
    </ul>
</div>
<!-- 顶部结束 -->
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 左侧菜单开始 -->
    <div class="left-nav">
        <div id="side-nav">
            <ul id="nav">
                <li class="list" current>
                    <a href="htindex">
                        <i class="iconfont">&#xe761;</i>
                        欢迎页面
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                </li>
                <li class="list">
                    <a href="javascript:;">
                        <i class="iconfont">&#xe70b;</i>
                        商品管理
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            <a href="htgoodslist">
                                <i class="iconfont">&#xe6a7;</i>
                                商品列表
                            </a>
                        </li>
                        <li>
                            <a href="goodscategory">
                                <i class="iconfont">&#xe6a7;</i>
                                商品分类
                            </a>
                        </li>
                        <li>
                            <a href="goodsadd">
                                <i class="iconfont">&#xe6a7;</i>
                                商品添加
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="list" >
                    <a href="javascript:;">
                        <i class="iconfont">&#xe6a3;</i>
                        订单管理
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu">
                        <li>
                            <a href="htorders">
                                <i class="iconfont">&#xe6a7;</i>
                                订单列表
                            </a>
                        </li>
                    </ul>
                </li>
                <li class="list" >
                    <a href="javascript:;">
                        <i class="iconfont">&#xe6a3;</i>
                        用户管理
                        <i class="iconfont nav_right">&#xe697;</i>
                    </a>
                    <ul class="sub-menu" style="display:none">
                        <li>
                            <a href="/htuser">
                                <i class="iconfont">&#xe6a7;</i>
                                用户列表
                            </a>
                        </li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <!-- 左侧菜单结束 -->
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <h2>一级分类：</h2>
            <!-- 右侧内容框架，更改从这里开始 -->
            <xblock><button class="layui-btn" onclick="member_add('添加类别','goodscategory?v=categoryaddone','600','500')"><i class="layui-icon">&#xe608;</i>添加</button></xblock>
            <table class="layui-table" id="LAY-fenlei-one">
                <thead>
                <tr>
                    <th>
                        类别ID
                    </th>
                    <th>
                        类别名称
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>

                <tbody>
                <c:forEach items="${successions}" var="x">
                    <tr>
                        <td >
                                ${x.xid}
                        </td>
                        <td >
                                ${x.xname}
                        </td>
                        <td class="td-manage">
                            <a style="text-decoration:none"  onclick="member_edit('修改类别名称','goodscategoryedit?v=goodscategoryeditone&xid=${x.xid}&xname=${x.xname}','10001','600','400')"
                               href="javascript:;" title="修改类别名称">
                                <i class="layui-icon" style="font-size: 20px">&#xe631;</i>
                            </a>
                            <a title="删除" href="javascript:;" onclick="member_delone(this,${x.xid})"
                               style="text-decoration:none">
                                <i class="layui-icon" style="font-size: 20px">&#xe640;</i>
                            </a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>


    <div class="page-content">
        <div class="content">
            <h2>二级分类：</h2>
            <!-- 右侧内容框架，更改从这里开始 -->
            <xblock><button class="layui-btn" onclick="member_add('添加类别','goodscategory?v=categoryadd','600','500')"><i class="layui-icon">&#xe608;</i>添加</button></xblock>
            <table class="layui-table" id="LAY-fenlei-two">
                <thead>
                <tr>
                    <th>
                        类别ID
                    </th>
                    <th>
                        类别名称
                    </th>
                    <th>
                        所属一级分类id
                    </th>
                    <th>
                        操作
                    </th>
                </tr>
                </thead>

                <tbody>
                <c:forEach items="${classifications}" var="x">
                    <tr>
                        <td >
                                ${x.lid}
                        </td>
                        <td >
                                ${x.lname}
                        </td>
                        <td >
                                ${x.xid}
                        </td>
                        <td class="td-manage">
                            <a style="text-decoration:none"  onclick="member_edit('修改类别名称','goodscategoryedit?lid=${x.lid}&lname=${x.lname}','10001','600','400')"
                               href="javascript:;" title="修改类别名称">
                                <i class="layui-icon" style="font-size: 20px">&#xe631;</i>
                            </a>
                            <a title="删除" href="javascript:;" onclick="member_del(this,${x.lid})"
                               style="text-decoration:none">
                                <i class="layui-icon" style="font-size: 20px">&#xe640;</i>
                            </a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<!-- 底部开始 -->

<!-- 底部结束 -->
<!-- 背景切换开始 -->
<div class="bg-changer">
    <div class="swiper-container changer-list">
        <div class="swiper-wrapper">
            <div class="swiper-slide"><img class="item" src="../x-admin/images/a.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/b.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/c.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/d.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/e.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/f.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/g.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/h.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/i.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/j.jpg" alt=""></div>
            <div class="swiper-slide"><img class="item" src="../x-admin/images/k.jpg" alt=""></div>
            <div class="swiper-slide"><span class="reset">初始化</span></div>
        </div>
    </div>
    <div class="bg-out"></div>
    <div id="changer-set"><i class="iconfont">&#xe696;</i></div>
</div>
<!-- 背景切换结束 -->
<!-- 页面动态效果 -->
<script>
    function member_delone(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            console.log("要删除的id="+id);
            if (id!=null) {
                $.ajax({
                    url: "/goodscategory?v=categorydelone",
                    type: "post",
                    data: {
                        id
                    },
                    success: (r => {
                        if (r > 0) {
                            layer.msg("已删除！", {icon: 1, time: 1000}, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                //修改成功后刷新父界面
                                window.parent.location.reload();
                            });
                        } else {
                            layer.msg("删除失败！请先删除该分类下的二级分类！", {icon: 2 ,time: 1000});
                            window.setTimeout(function () {
                                window.location.reload();
                            },1000)
                        }
                    })
                })
            }else{
                console.log("要删除的id为空!!");
            }
        });
    }

    /*类别-删除*/
    function member_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $(obj).parents("tr").remove();
            console.log("要删除的id="+id);
            if (id!=null) {
                $.ajax({
                    url: "/goodscategory?v=categorydel",
                    type: "post",
                    data: {
                        id
                    },
                    success: (r => {
                        if (r > 0) {
                            layer.msg("已删除！", {icon: 1, time: 1000}, function () {
                                // 获得frame索引
                                var index = parent.layer.getFrameIndex(window.name);
                                //关闭当前frame
                                parent.layer.close(index);
                                //修改成功后刷新父界面
                                window.parent.location.reload();
                            });
                        } else {
                            layer.msg("删除失败！请先删除该分类下的所有商品！", {icon: 2 ,time: 1000});
                            window.setTimeout(function () {
                                window.location.reload();
                            },1000)
                        }
                    })
                })
            }else{
                console.log("要删除的id为空!!");
            }
        });
    }

    //类别添加
    function member_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

    //查看详情
    function member_edit (title,url,id,w,h) {
        x_admin_show(title,url,w,h);
    }

</script>

</body>
</html>